#include <stdio.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <string.h>
#include <unistd.h>


int main(int argc, const char *argv[])
{
	int fd = open("./1.txt",O_RDWR|O_CREAT,0664);
	char writebuf[128]={0};
//	scanf("%s",writebuf);
	fgets(writebuf,128,stdin);
	lseek(fd,0,SEEK_END);
	write(fd,writebuf,strlen(writebuf));


	lseek(fd,0,SEEK_SET);
	char readbuf[128]={0};
	read(fd,readbuf,sizeof(readbuf));
	printf("%s\n",readbuf);

	close(fd);
	return 0;
}
